<?php 
include("includes/code.php");

if (isset($_GET['id'])) { $id= $_GET['id']; }

$result = mysql_query("SELECT cat,title,text,date,price,img_mini,img,img2,img3,view FROM data WHERE id='$id'",$db);
if (!$result)
{ myerror("XATOLIK ! Bazadagi data jadvalidan tovar olinmadi"); }

if (mysql_num_rows($result) > 0)
{
$myrow = mysql_fetch_array($result);
// view 1 ta ga oshiriladi
$new_view = $myrow["view"] + 1;
mysql_query("UPDATE data SET view='$new_view' WHERE id='$id'");
// view finish
}
else { myerror("Saytda bunday tovar mavjud emas, <a href='index.php'>Bosh sahifaga o'tish</a>"); }

$cat = $myrow["cat"];
$tovarname = $myrow["title"];
$text = $myrow["text"];
$price = $myrow["price"];
$date = $myrow["date"];
$img_mini = $myrow["img_mini"];
$img = $myrow["img"];
$img2 = $myrow["img2"];
$img3 = $myrow["img3"];
$view = $myrow["view"];
$date = $myrow["date"];
	  
$tovarname = htmlspecialchars(stripslashes($tovarname));
$text = nl2br(stripslashes($text));
/* endi usha kategoriyani menudan nomini olamiz */
$result2 = mysql_query("SELECT title,parent FROM menu WHERE id='$cat'",$db);
if (!$result2)
{ myerror("XATOLIK! menu jadvalidan malumot olinmadi");  }
$myrow2 = mysql_fetch_array($result2);

$parent = $myrow2["parent"];
$title = stripslashes($myrow2["title"])." &nbsp; &gt; &nbsp; ";

/// podkategoriyaga kirganda uzidan yuqoridagisini kursatamiz
$result_parent = mysql_query("SELECT title FROM menu WHERE id='$parent'",$db);
if(mysql_num_rows($result_parent) > 0)
{
$row_parent = mysql_fetch_array($result_parent);
$title_parent = stripslashes($row_parent['title'])." &nbsp; &gt; &nbsp; ";
}
$title = $title_parent . $title . $tovarname;

///// headerni olamiz
include("includes/header.php"); 
?>

<!-- highslide start -->
<script type="text/javascript" src="highslide/highslide-with-gallery.js"></script>
<link rel="stylesheet" type="text/css" href="highslide/highslide.css" />
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="highslide/highslide-ie6.css" />
<![endif]-->
<!--
    2) Optionally override the settings defined at the top
    of the highslide.js file. The parameter hs.graphicsDir is important!
-->
<script type="text/javascript">
hs.graphicsDir = 'highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.fadeInOut = true;
hs.outlineType = 'rounded-white';
hs.wrapperClassName = 'dark';
hs.captionEval = 'this.a.title';
hs.numberPosition = 'caption';
hs.useBox = true;
hs.width = 600;
hs.height = 400;
//hs.dimmingOpacity = 0.8;

// Add the slideshow providing the controlbar and the thumbstrip
hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		position: 'bottom center',
		opacity: 0.75,
		hideOnMouseOut: true
	},
	thumbstrip: {
		position: 'above',
		mode: 'horizontal',
		relativeTo: 'expander'
	}
});

// Make all images animate to the one visible thumbnail
var miniGalleryOptions1 = {
	thumbnailId: 'thumb1'
}
</script>

<!-- content and sidebar -->
<div id="main">
<table class="main_table" cellspacing="0" cellpadding="0">
  <tr valign="top">
    <td class="left_col">
<!-- ------------- left start ------------- -->
<?php include("includes/left.php"); ?>
    
<!-- ----------------- left finish ---------------- -->
    </td>
    <td>
<div class="content">
<!-- content start -->

<h4 class="sarlavha"><?php echo $title ?></h4>

<!-- tovar haqida batafsil -->
<div class="batafsil">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr valign="top">
    <td width="30%">
    <div class="tovar_view">
    	<div class="highslide-gallery">
<?php 
if(empty($img_mini)) { $img_mini = "fotos/nofoto.jpg"; $img = "fotos/nofoto.jpg"; }
if(empty($img2)) { $img2 = "fotos/nofoto.jpg"; }
if(empty($img3)) { $img3 = "fotos/nofoto.jpg"; }

echo "
<a class='highslide' id='thumb1' href='".$img."' onclick='return hs.expand(this, miniGalleryOptions1)'>
<img src='".$img_mini."' alt=''/> 
</a>

<div class='hidden-container'>
<a class='highslide' href='".$img2."' onclick='return hs.expand(this, miniGalleryOptions1)'> <img src='".$img2."' alt='' /></a>
<a class='highslide' href='".$img3."' onclick='return hs.expand(this, miniGalleryOptions1)'> <img src='".$img3."' alt='' /></a>
</div>";
?>
    	<p class="zoom"><img src="themes/default/img/zoom.png" alt="Zoom" align="absmiddle" /> <?php echo ZOOM; ?> </p>
    	</div>
    </div>
    </td>
    <td>
    <a name="form"></a>
    <h4 class="tovarnomi"><?php echo $tovarname; ?></h4>
    <p>
    <?php echo $text; ?><br /><br />
    <?php echo PRICE. $price; ?><br />
    <span class="date"><?php echo DATE_ADD. $date; ?></span> <br />
    <span class="date"><?php echo VIEWED. $view; ?></span> <br /><br />
   
    <a href="cart.php?action=add&id=<?=$id ?>">
    <img src="themes/default/img/add.png" alt="Buy" align="absmiddle" title="Add to cart" /></a>
    &nbsp; 
    <a href="#form"><?php echo PURCHASE; ?></a> 
    
    </p>
    </td>
  </tr>
</table>
<!-- order forma start ... quyida display:none qilsa buladi -->
    <div id="orderform">
    <?php include("includes/order_form.php"); ?>
    </div>
<!-- order forma finish -->
</div>
<!-- tovar haqida batafsil // -->

<h4 class="sarlavha"> <?php echo $lang['recomend'] ?> </h4>
<!-- yana taklif -->
<?php 
tovarlar("recomend");
?>
<div style="clear:both"></div><br>
<p><a href="all.php"><?=$lang['all'] ?></a></p>
<!-- yana taklif // --> 

<!-- content finish -->
</div>
    </td>
    <td class="right_col">
<!-- -------- right start ----------- -->
<?php include("includes/right.php"); ?>
<!-- --------- right finish ------- -->
    </td>
  </tr>
</table>

</div>
<!-- content and sidebar finish -->

</div>
<!-- main container finish -->
<?php include("includes/footer.php"); ?>